<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>jaspi</title>
</head>

<body>

    {:dump($jsApiParameters)}

</body>

<script>

    //调用微信JS api 支付
    function jsApiCall() {
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest',
            {
                "appId": "{$jsApiParameters.appId}",           //公众号名称，由商户传入
                "timeStamp": "{$jsApiParameters.timeStamp}",   //时间戳，自1970年以来的秒数
                "nonceStr": "{$jsApiParameters.nonceStr}",     //随机串
                "package": "{$jsApiParameters.package}",
                "signType": "{$jsApiParameters.signType}",     //微信签名方式：
                "paySign": "{$jsApiParameters.paySign}"        //微信签名
            },
            function (res) {
                WeixinJSBridge.log(res.err_msg);
                //alert(res.err_code+res.err_desc+res.err_msg);
                if (res.err_msg == "get_brand_wcpay_request:ok") {
                    alert("支付成功!");
                    // 支付成功可以进行页面跳转
                    window.location.href = "/";
                } else if (res.err_msg == "get_brand_wcpay_request:cancel") {
                    alert("用户取消支付!");
                } else {
                    alert("支付失败!");
                }
            }
        );
    }

    if (typeof WeixinJSBridge == "undefined") {
        if (document.addEventListener) {
            document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
        } else if (document.attachEvent) {
            document.attachEvent('WeixinJSBridgeReady', jsApiCall);
            document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
        }
    } else {
        jsApiCall();
    }

</script>

</html>